Optimizing host CPU usage based on virtual machine guest OS power and performance management

ABSTRACT

Techniques for optimizing CPU usage in a host system based on VM guest OS power and performance management are provided. In one embodiment, a hypervisor of the host system can capture information from a VM guest OS that pertains to a target power or performance state set by the guest OS for a vCPU of the VM. The hypervisor can then perform, based on the captured information, one or more actions that align usage of host CPU resources by the vCPU with the target power or performance state.

BACKGROUND

As known in the field of computer virtualization, a hypervisor is asoftware component that provides, on a physical machine (i.e., a hostsystem), an execution environment in which one or more virtual machines(VMs) can run. As part of its duties, the hypervisor provisions aportion of the physical hardware resources of the host system to each VMin the form of a virtual hardware platform (comprising, e.g., virtualCPU(s), guest virtual memory, etc.). A guest operating system (OS)running within each VM carries out workloads using the VM's virtualhardware platform, which causes those workloads to be executed on thehost physical hardware mapped to (i.e., backing) the virtual hardware.

For example, in a scenario where a VM is configured to have X virtualCPUs (vCPUs), the hypervisor will allocate to each vCPU a time slice ofa host CPU (typically determined by a user-defined CPU “share” or“limit” value). When the guest OS of the VM submits a workload to beexecuted using the VM's vCPUs, the hypervisor will schedule the workloadon the host CPUs that back the vCPUs. The hypervisor will generallyperform this scheduling in a manner that ensures the amount of host CPUtime (i.e., clock cycles) consumed by each vCPU does not exceed thevCPU's allocated share.

In some cases, the guest OS of a VM may support mechanisms that allow itto set desired power and/or performance states for its vCPU(s) based on,e.g., the nature of the workloads being executed or other criteria.Information regarding the vCPU power/performance states could be usefulto the hypervisor in more optimally managing the allocation and use ofhost CPU resources by each vCPU. However, existing hypervisors are notdesigned to support and/or leverage these VM-level power and performancemechanisms in order to facilitate host CPU resource optimization.

SUMMARY

Techniques for optimizing CPU usage in a host system based on VM guestOS power and performance management are provided. In one embodiment, ahypervisor of the host system can capture information from a VM guest OSthat pertains to a target power or performance state set by the guest OSfor a vCPU of the VM. The hypervisor can then perform, based on thecaptured information, one or more actions that align usage of host CPUresources by the vCPU with the target power or performance state.

The following detailed description and accompanying drawings provide abetter understanding of the nature and advantages of particularembodiments.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 depicts an example host system according to an embodiment.

FIG. 2 depicts a high-level workflow for optimizing host CPU usage basedon guest OS power/performance management according to an embodiment.

FIG. 3 depicts a workflow for implementing virtual CPU gating accordingto an embodiment.

FIG. 4 depicts a workflow for implementing virtual big.LITTLE accordingto an embodiment.

FIG. 5 depicts a workflow for implementing virtual CPU performancestates according to an embodiment.

DETAILED DESCRIPTION

In the following description, for purposes of explanation, numerousexamples and details are set forth in order to provide an understandingof various embodiments. It will be evident, however, to one skilled inthe art that certain embodiments can be practiced without some of thesedetails, or can be practiced with modifications or equivalents thereof.

1. Overview

Embodiments of the present disclosure provide techniques for optimizingthe use of host CPU resources by the vCPU(s) of a VM based on per-vCPUpower and/or performance management activities performed by the VM'sguest OS. At a high level, these techniques involve capturing, by ahypervisor, explicit cues generated by the guest OS regarding desired(i.e., target) power and/or performance states determined for each vCPU.Based on these explicit cues, the hypervisor can take one or moreactions that more closely align the vCPU's allocation/use of host CPUresources with the vCPU's target power or performance state, resultingin more efficient overall host CPU usage (as well as potentiallyimproved quality of service for each vCPU).

For example, according to one set of embodiments (referred to herein asthe “virtual CPU gating” approach), the hypervisor can trap instances ofa “CPU power off” instruction that is implemented in certain guest OSs.Upon trapping an instance of this instruction with respect to aparticular vCPU (e.g., vCPU1), the hypervisor can tear down state (alsoknown as “context”) information that it maintains for vCPU1, therebyde-scheduling vCPU1 from the host CPU(s) and making the host CPU timeslice previously allocated to vCPU1 available to other vCPUs in the sameor other VMs. This tear down action also advantageously frees hypervisormemory resources previously dedicated to vCPU1's context.

According to another set of embodiments (referred to herein as the“virtual big.LITTLE” approach), the hypervisor can expose a virtual CPUtopology comprising a cluster of higher performance vCPUs and a clusterof lower performance vCPUs to a guest OS that supports big.LITTLEscheduling optimizations. This type of topology is known as a“big.LITTLE” topology. Examples of such big.LITTLE schedulingoptimizations include clustered switching, in-kernel buddy switching,and fully heterogeneous use. By exposing a virtual big.LITTLE topologyto such a guest OS, two benefits are realized—first, the guest OS isempowered to implement its big.LITTLE scheduling optimizations for theVM's vCPUs, which necessarily results in more efficient host CPU usagein cases where the virtual big.LITTLE topology is backed by acorresponding physical big.LITTLE topology on the host (or in caseswhere the virtual big and little clusters are assigned different hostCPU time slices). Second, the hypervisor can recognize the big.LITTLEscheduling activities initiated by the guest OS and can take steps tofurther optimize host CPU usage based on this information. For instance,in a scenario where the guest OS swaps a workload from the virtual bigcluster to the virtual little cluster (thereby rendering the virtual bigcluster idle), the hypervisor can tear down the vCPU contexts associatedwith the virtual big cluster after some predetermined timeout period.Other types of hypervisor-level actions are also possible depending onthe nature of the big.LITTLE optimizations implemented at the VM level.

According to yet another set of embodiments (referred to herein as the“virtual CPU performance states” approach), the hypervisor can expose tothe guest OS of a VM a mechanism for setting performance states for theVM's vCPU(s), as modeled under the ACPI Collaborative ProcessorPerformance Control (CPPC) or “P-states” standards. One or both of thesestandards are supported by most modern operating systems. At the timethe guest OS sets a particular performance state (e.g., S1) for aparticular vCPU of the VM (e.g., vCPU1), the hypervisor can trap thestate setting action, determine an appropriate host CPU time slice forvCPU1 based on state S1, and then modify vCPU1's allocated time slice inaccordance with the determined time slice. In this way, the hypervisorcan dynamically dial up or dial down the host CPU resources allocated to(and thus used by) each vCPU in synchrony with the vCPU's guestOS-controlled target performance level.

The foregoing and other aspects of the present disclosure are describedin further detail in the sections that follow.

2. Example Host System and High-Level Design

FIG. 1 depicts an example host system 100 in which embodiments of thepresent disclosure may be implemented. As shown, host system 100includes a software layer 102 that comprises a hypervisor 104 and a VM106. Although only one VM is depicted for purposes of illustration, anynumber of VMs may be supported. VM 106 includes a guest OS 108 thatexecutes on top of a virtual hardware platform 110 provisioned byhypervisor 104.

In addition to software layer 102, host system 100 includes a hardwarelayer 112 that comprises, among other things, a number of host centralprocessing units (CPUs) 114(1)-(N). As used herein, a “CPU” is acomputing element that is capable of independently executing a softwareprocess or thread. In one set of embodiments, host CPUs 114(1)-(N) maybe homogeneous CPUs—in other words, CPUs that are identical orsubstantially similar in terms of their compute performance. In otherembodiments, host CPUs 114(1)-(N) may include heterogeneous CPUs withsubstantially different performance characteristics. For instance, in aparticular embodiment (discussed in section (4) below), host CPUs114(1)-(N) may be part of a physical big.LITTLE CPU topology comprisinga cluster of higher performance CPUs and a cluster of lower performanceCPUs.

In the example of FIG. 1, hypervisor 104 is configured to provision aportion (e.g., time slice) of each host CPU 114 to VM 106 in the form ofa corresponding virtual CPU (vCPU) 116. These vCPUs 116(1)-(N) areexposed to guest OS 108 of VM 106 as part of virtual hardware platform110.

As noted the Background section, some guest OSs supportpower/performance management mechanisms that allow the guest OS to settarget power and/or performance states for its vCPUs based on variouscriteria (e.g., CPU load balancing, power efficiency objectives, etc.).Information regarding these vCPU power/performance states would behighly useful to the hypervisor in efficiently managing host CPUallocation and usage among its VMs/vCPUs; unfortunately, existinghypervisor implementations generally cannot capture and take advantageof this information. In fact, for certain power/performance managementmechanisms such as big.LITTLE CPU scheduling, existing hypervisors arenot designed to expose appropriate virtual hardware to VMs in a mannerthat enables the VM guest OSs to execute the mechanisms in the firstplace.

To address these and other similar deficiencies, hypervisor 104 of FIG.1 can be enhanced to carry out high-level workflow 200 depicted in FIG.2 according to embodiments of the present disclosure. As shown in FIG.2, hypervisor 104 can first empower guest OS 108 of VM 106 to execute avCPU power/performance management mechanism that is supported by theguest OS (block 202). For example, if the mechanism is big.LITTLE CPUscheduling, hypervisor 104 can expose to guest OS 108 a virtualbig.LITTLE CPU topology comprising a cluster of higher performance vCPUsand a cluster of lower performance vCPUs. As another example, if themechanism is ACPI CPPC-based CPU performance state management,hypervisor 104 can emulate appropriate system registers that enableguest OS 108 to read and set vCPU CPPC performance states. In caseswhere hypervisor 104 does not need to take any steps in order to empowerVM-level execution of the mechanism, block 202 can be omitted.

At block 204, while guest OS 108 is running the power/performancemanagement mechanism, hypervisor 104 can capture one or more explicitcues that are generated by guest OS 108 with respect to establishing atarget power or performance state for a particular vCPU 116. In one setof embodiments, this can entail trapping a specific command orinstruction that is issued by the guest OS for setting the target poweror performance state (e.g., a CPU power off instruction, a write to aCPPC register, etc.). In other embodiments, this can entail capturinginformation regarding other types of VM-level actions that are relatedto a power/performance management activity.

Then, at block 206, hypervisor 104 can take one or more actions thatadjust the vCPU's allocation/usage of host CPU resources in a mannerthat brings that allocation/usage in line with the vCPU's target poweror performance state as captured at block 204. In various embodimentsthese actions can include, e.g., tearing down hypervisor-level vCPUcontext information for a vCPU that has been idled or powered off,dynamically modifying the amount of host CPU time (e.g., CPU time slice)allocated to the vCPU, migrating the vCPU from one host CPU to anotherhost CPU, and others. In these ways, hypervisor 104 can advantageouslyoptimize the allocation/use of host CPU resources among the vCPUs ofhost system 100 in direct response to the power/performance managementactivities executed at, and gleaned from, the VM level. In addition, asa corollary, the actions taken by hypervisor 104 at block 206 caneffectively tune the quality of service provided by each vCPU to bettermatch the guest OS's desired power/performance goals.

The remaining sections of this disclosure provide details regardingthree approaches for implementing high-level workflow 200 of FIG. 2: (1)virtual CPU gating, (2) virtual big.LITTLE, and (3) virtual CPUperformance states. Although these approaches are discussed separately,it should be appreciated that two or more of the approaches may beimplemented concurrently with respect to the same VM or different VMs ona given host system. Further, it should be appreciated that theseapproaches are illustrative in nature and other possible approaches ortechniques for implementing workflow 200 of FIG. 2 are contemplated tobe within the scope of the present disclosure.

3. Virtual CPU Gating

Certain CPU architectures, and the OSs that are designed to run on thoseCPU architectures, support a power management interface that allows theOSs to turn off one or more CPUs during system runtime in order toconserve power or for other purposes. One example of this is the PowerState Coordination Interface (PSCI) that is supported by the ARM64architecture and ARM64-based OSs like ARM64 Linux. In cases where suchan OS is used as a guest OS in a VM, the hypervisor running the VM canimplement a virtual CPU gating approach that generally involves (1)detecting a CPU power off instruction issued by the guest OS withrespect to a vCPU, and (2) tearing down context information maintainedby the hypervisor for that vCPU (since the vCPU has been powered off andno longer needs to be scheduled on the host CPU(s)). In this manner, thehypervisor can free host CPU resources previously allocated to the vCPUand can also free hypervisor memory and compute resources previouslydedicated to managing/scheduling the vCPU. FIG. 3 depicts a workflow 300that details this virtual CPU gating approach according to anembodiment.

At block 302, a VM guest OS (which may be, e.g., an ARM64-based OS orany other OS supporting CPU power off) can determine that a particularvCPU (e.g., vCPU1) of the VM no longer needs to be powered on. Forexample, in one embodiment, the guest OS may be configured to compactthe workloads running in the VM on a periodic basis and, upon performingsuch a compaction, may find that the VM's workloads can be sufficientlyrun on vCPUs other than vCPU1.

In response to the determination at block 302, the guest OS can issue aCPU power off instruction with respect to vCPU1 (block 304). In the caseof an ARM64-based OS, this instruction can specifically correspond to a“PSCI OFF” command. In the case of other OSs, this instruction cancorrespond to whatever instruction is exposed by the CPU powermanagement interface supported by the OS for initiating a CPU power offaction.

At block 306, the hypervisor running the VM can “trap” the CPU power offinstruction. Stated another way, the issuance of the CPU power offinstruction can trigger a hardware interrupt that causes the host CPUprocessing the command to transition, or “exit,” into a privilegedkernel mode in which the hypervisor takes control. As part of this exitprocess, the hypervisor is made aware that the CPU power off instructionwas issued by the guest OS (and was the reason for the exit).

Then, upon trapping the CPU power off instruction, the hypervisor cantear down the hypervisor-level context that is associated withpowered-off vCPU1 (block 308). This final step can entail, e.g.,deleting from host memory any data structures that are used by thehypervisor for maintaining the execution state of vCPU1, as well asde-scheduling vCPU1 from the host CPU(s) of the system.

4. Virtual Big.LITTLE

The virtual big.LITTLE approach is premised on the notion of presenting,to a VM guest OS that supports big.LITTLE scheduling optimizations (suchas various ARM-based OSs), a heterogeneous vCPU topology that comprisesa cluster of higher performance (i.e., big) vCPUs and a cluster of lowerperformance (i.e., little) vCPUs. In one set of embodiments, thisvirtual big.LITTLE topology may be backed by a corresponding physicalbig.LITTLE CPU topology on the host system. In another set ofembodiments, the virtual big.LITTLE topology may map to a homogenous CPUtopology on the host system.

In either case, the presentation of a virtual big.LITTLE topology to theguest OS results in two beneficial consequences. First, the guest OS isempowered to execute its supported big.LITTLE scheduling optimizations(e.g., cluster switching, in-kernel buddy switching, or fullyheterogeneous use) with respect to the VM's vCPUs, which will generallyresult in more efficient CPU usage at the host level. Second, thehypervisor is able to capture information regarding the big.LITTLEscheduling activities performed by the guest OS, which the hypervisorcan then leverage to further optimize host CPU allocation/usage amongthe host's VMs and vCPUs.

FIG. 4 depicts a workflow 400 can be performed by a hypervisor and abig.LITTLE-aware VM guest OS for implementing virtual big.LITTLEaccording to an embodiment. Starting with block 402, the hypervisor canexpose, to the guest OS, a virtual big.LITTLE CPU topology including acluster of big vCPUs and a cluster of little vCPUs. By way of example,if the virtual big.LITTLE topology comprises ARM vCPUs, the big vCPUsmay be Cortex A57 cores while the little vCPUs may be Cortex A53 cores.

As mentioned previously, the virtual big.LITTLE topology may be backedon the host system by either (1) a physical big.LITTLE CPU topology or(2) a physical homogeneous CPU topology. In scenario (1), each big vCPUwill be mapped to a respective big CPU on the host and each little vCPUwill be mapped to respective little CPU on the host. In scenario (2),each big and little vCPU will be mapped to a homogenous host CPU. Inthis latter case, the CPU time slice assigned to the big vCPUs can bemade larger than the CPU time slice assigned to the little vCPUs inorder to emulate their differing performance characteristics. Forexample, the big vCPU cluster may be assigned a CPU time slice of 10%(indicating that each big vCPU is allocated 10% of the clock cycles ofthe backing host CPU) while the little vCPU cluster may be assigned aCPU time slice of 5% (indicating that each little vCPU is allocated 5%of the clock cycles of the backing host CPU). These per-cluster timeslices can be defined by the hypervisor or a user and can be maintainedin a configuration file (e.g., VMX file) of the VM.

The specific process by which the hypervisor exposes the virtualbig.LITTLE CPU topology to the guest OS at block 402 can involvereporting, to the guest OS, processor identifiers (IDs) that reflecteach vCPU's performance class (e.g., reporting the big vCPUs as highperformance A57 cores and the little vCPUs as low performance A53cores). In scenario (1) above, this reporting can be achieved by passingthrough the processor ID of the backing big or little host CPU to theguest OS via a predefined vCPU register (e.g., the VPIDR_EL2 registerfor ARM CPUs). In scenario (2) above, this reporting can be achieved byoverriding the host CPU processor ID to reflect a big or little CPU asappropriate and writing the overridden processor ID to the predefinedvCPU register.

In cases where the guest OS also expects a firmware-level device treeenumerating the CPUs of the system (this typically applies to OSs forembedded systems), the process at block 402 may further involveincluding device tree definitions for the virtual big.LITTLE topology inthe VM's firmware configuration file(s). The listing below illustratesexample device tree definitions for a topology comprising two A57 coresand two A53 cores:

Listing 1 cpus {   #address-cells = <1>;   #size-cells = <0>;   cpu0:cpu at 100 {     device_type = “cpu”;     compatible = “arm,cortex-a53”,“arm,armv8”;     enable-method = “psci”;     reg = <0x100>;     };  cpu1: cpu at 101 {     device_type = “cpu”;     compatible =“arm,cortex-a53”, “arm,armv8”;     enable-method = “psci”;     reg =<0x101>;   };     cpu2: cpu at 0 {     device_type = “cpu”;    compatible = “arm,cortex-a57”, “arm,armv8”;     enable-method =“psci”;     reg = <0x000>;     };     cpu3: cpu at 1 {     device_type =“cpu”;     compatible = “arm,cortex-a57”, “arm,armv8”;     enable-method= “psci”;     reg = <0x001>;   }; };

Once the hypervisor has exposed the virtual big.LITTLE topology to theguest OS, the guest OS can run VM workloads on the topology per itsnormal operation and, as part of this, can use its big.LITTLEcapabilities to optimize scheduling of the workloads on the virtual bigand little clusters (block 404). This will generally result in moreefficient and effective host CPU usage. For example, assume that thevirtual big.LITTLE topology is backed by a physical big.LITTLE topology.In this case, if the guest OS moves a workload from the virtual bigcluster to the virtual little cluster because, e.g., the workload is notcompute intensive, that workload will also be moved from the physicalbig cluster to the physical little cluster, thereby increasing theavailable compute capacity of the physical big cluster for other tasks.Conversely, if the guest OS moves a workload from the virtual littlecluster to the virtual big cluster because, e.g., the workload requiresmore compute resources, that workload will also be moved from thephysical little cluster to the physical big cluster, resulting in morehost CPU power being devoted to the workload.

Similar logic applies in the scenario where the virtual big.LITTLEtopology is backed by a physical homogenous CPU topology. In this case,since the vCPUs of the virtual little cluster are assigned a smallerhost CPU time slice than the vCPUs of the virtual big cluster as notedabove, any switching of work from the virtual big cluster to the virtuallittle cluster will result in more efficient use of physical CPUresources, and any switching of work from the virtual little cluster tothe virtual big cluster will enable more physical CPU time to be devotedto that work.

Finally, at blocks 406 and 408 of workflow 400, the hypervisor cancapture information from the guest OS regarding the guest OS'sscheduling of work on the virtual big.LITTLE topology and, using thisinformation, can take one or more actions to further optimize host CPUusage. For example, if the hypervisor sees that the guest OS has idledthe virtual big cluster, after some threshold period of time thehypervisor can release the vCPU contexts associated with the vCPUs inthat cluster. As another example, if the hypervisor sees that the guestOS has modified the load on one or more vCPUs, the hypervisor candynamically modify the host CPU time slice allocated to those vCPUs, orchange the placement of the vCPUs on the physical CPU topology (e.g.,move the vCPU from the physical little cluster to the physical bigcluster or vice versa). One of ordinary skill in the art will recognizeother variations, modifications, and alternatives for the actions thatmay be taken by the hypervisor at block 406.

One potential issue with the virtual big.LITTLE approach shown in FIG. 4is VM migration. For instance, consider a scenario where a VM running ona source host system is presented a virtual big.LITTLE CPU topology thatis backed by a physical big.LITTLE CPU topology, and the VM issubsequently migrated to a destination host system that does not supportphysical big.LITTLE (i.e., the destination host has homogenous physicalCPUs). In this scenario, the little vCPUs of the VM will be assigned ahost CPU time slice that will be relative to the physical little CPUs onthe source host system, and thus this time slice value will not beappropriate after the migration to the destination host system (sincethe homogenous CPUs on the destination will have different performancecharacteristics than the little CPUs on the source).

To address this, in certain embodiments the vCPU topology of the VM maybe assigned three different CPU time slice values: a first value thatapplies to the virtual big cluster, a second value that applies to thevirtual little cluster in the specific case where the virtual littlecluster is backed by a physical little cluster, and a third value thatapplies to the virtual little cluster in the specific case where thevirtual little cluster is not backed by a physical little cluster. Withthis solution, the second value can used while the VM is running on ahost system with a physical big.LITTLE topology (e.g., the source hostin the example above) and the third value can be used while the VM isrunning on a host system with a homogenous CPU topology (e.g., thedestination host in the example above).

5. Virtual CPU Performance States

The virtual CPU performance states approach takes advantage of the ACPICPPC (or older “P-states”) standard that is supported by most modern OSsto facilitate host CPU resource optimization. As known in the art, ACPICPPC is a CPU architecture-agnostic framework that enables an OS tomanage the performance of a system's CPUs. In particular, CPPC comprisesa number of performance control registers (defined per-CPU) that the OSuses to read out and set the performance level (i.e., state) of eachCPU. The performance states can be defined as a function of CPUfrequency, power scaling, and/or other factors. CPPC also comprisesper-CPU data structures that describe to the OS the hardwarecapabilities of each CPU and the locations of the CPU's performancecontrol registers.

With the virtual CPU performance states approach, a hypervisor canemulate the performance control registers for each vCPU of a VM and canexpose these emulated registers to the VM's guest OS. This enables theguest OS to set performance states for the vCPUs via the emulatedregisters, per the guest OS's in-built ACPI CPPC capabilities. Upondetecting the establishment of a vCPU CPPC performance state (i.e., awrite to the vCPU's performance control register(s)), the hypervisor canuse the state information to dynamically modify the host CPU time sliceallocated to the vCPU (and/or the vCPU's placement on the host CPUtopology). In this way, the hypervisor can tune the amount of physicalCPU resources available to the vCPU based on the vCPU's target CPPCperformance level. FIG. 5 depicts a workflow 500 that details thisprocess according to an embodiment.

At block 502, a hypervisor can, for each vCPU of a VM, emulateperformance control registers of the vCPU (per, e.g., the ACPI CPPCstandard) and can expose the emulated performance control registers tothe VM's guest OS. In one embodiment, the hypervisor can perform thisemulation by defining a portion of the guest virtual memory of the VM asrepresenting the performance control registers and trapping access toit. In another embodiment, the hypervisor can perform this emulationusing ACPI Platform Communication Channel (PCC), which is a sharedmemory communication channel. In yet another embodiment, the hypervisorcan perform this emulation using “fixed function hardware” defined forthe vCPUs.

At block 504, the guest OS can read out, using the emulated performancecontrol registers, the available performance states for the vCPUs. Theseperformance states are defined in per-vCPU ACPI data structures whichcan be stored in one or more firmware configuration files of the VM.Further, at block 506, the guest OS can set a particular performancestate (e.g., S1) for a particular vCPU (e.g., vCPU1) by writing theperformance state to one or more of the vCPU1's emulated performancecontrol registers.

At block 508, the hypervisor can trap the write and thereby determinethat the performance state for vCPU1 has been set to S1. Finally, atblock 510, the hypervisor can use this performance state information todynamically change the scheduling behavior of vCPU1 on the host CPU(s).For instance, in one embodiment the hypervisor increase or decrease thehost CPU time slice allocated to vCPU1, depending on whether the vCPUhas transitioned to a higher performance or lower performance state. Inother embodiments, the hypervisor can take other actions, such aschanging the placement of the vCPU1 on the host CPU topology, changinghardware thread priorities (if the vCPUs are mapped to hardwarethreads), and so on.

Certain embodiments described herein involve a hardware abstractionlayer on top of a host computer. The hardware abstraction layer allowsmultiple containers to share the hardware resource. These containers,isolated from each other, have at least a user application runningtherein. The hardware abstraction layer thus provides benefits ofresource isolation and allocation among the containers. In the foregoingembodiments, virtual machines are used as an example for the containersand hypervisors as an example for the hardware abstraction layer. Asdescribed above, each virtual machine includes a guest operating systemin which at least one application runs. It should be noted that theseembodiments may also apply to other examples of containers, such ascontainers not including a guest operating system, referred to herein as“OS-less containers” (see, e.g., www.docker.com). OS-less containersimplement operating system-level virtualization, wherein an abstractionlayer is provided on top of the kernel of an operating system on a hostcomputer. The abstraction layer supports multiple OS-less containerseach including an application and its dependencies. Each OS-lesscontainer runs as an isolated process in userspace on the host operatingsystem and shares the kernel with other containers. The OS-lesscontainer relies on the kernel's functionality to make use of resourceisolation (CPU, memory, block I/O, network, etc.) and separatenamespaces and to completely isolate the application's view of theoperating environments. By using OS-less containers, resources can beisolated, services restricted, and processes provisioned to have aprivate view of the operating system with their own process ID space,file system structure, and network interfaces. Multiple containers canshare the same kernel, but each container can be constrained to only usea defined amount of resources such as CPU, memory and I/O.

Further embodiments described herein can employ variouscomputer-implemented operations involving data stored in computersystems. For example, these operations can require physical manipulationof physical quantities—usually, though not necessarily, these quantitiestake the form of electrical or magnetic signals, where they (orrepresentations of them) are capable of being stored, transferred,combined, compared, or otherwise manipulated. Such manipulations areoften referred to in terms such as producing, identifying, determining,comparing, etc. Any operations described herein that form part of one ormore embodiments can be useful machine operations.

Yet further, one or more embodiments can relate to a device or anapparatus for performing the foregoing operations. The apparatus can bespecially constructed for specific required purposes, or it can be ageneral purpose computer system selectively activated or configured byprogram code stored in the computer system. In particular, variousgeneral purpose machines may be used with computer programs written inaccordance with the teachings herein, or it may be more convenient toconstruct a more specialized apparatus to perform the requiredoperations. The various embodiments described herein can be practicedwith other computer system configurations including handheld devices,microprocessor systems, microprocessor-based or programmable consumerelectronics, minicomputers, mainframe computers, and the like.

Yet further, one or more embodiments can be implemented as one or morecomputer programs or as one or more computer program modules embodied inone or more non-transitory computer readable storage media. The termnon-transitory computer readable storage medium refers to any datastorage device that can store data which can thereafter be input to acomputer system. The non-transitory computer readable media may be basedon any existing or subsequently developed technology for embodyingcomputer programs in a manner that enables them to be read by a computersystem. Examples of non-transitory computer readable media include ahard drive, network attached storage (NAS), read-only memory,random-access memory, flash-based nonvolatile memory (e.g., a flashmemory card or a solid state disk), a CD (Compact Disc) (e.g., CD-ROM,CD-R, CD-RW, etc.), a DVD (Digital Versatile Disc), a magnetic tape, andother optical and non-optical data storage devices. The non-transitorycomputer readable media can also be distributed over a network coupledcomputer system so that the computer readable code is stored andexecuted in a distributed fashion.

In addition, while described virtualization methods have generallyassumed that virtual machines present interfaces consistent with aparticular hardware system, persons of ordinary skill in the art willrecognize that the methods described can be used in conjunction withvirtualizations that do not correspond directly to any particularhardware system. Virtualization systems in accordance with the variousembodiments, implemented as hosted embodiments, non-hosted embodimentsor as embodiments that tend to blur distinctions between the two, areall envisioned. Furthermore, certain virtualization operations can bewholly or partially implemented in hardware.

Many variations, modifications, additions, and improvements arepossible, regardless the degree of virtualization. The virtualizationsoftware can therefore include components of a host, console, or guestoperating system that performs virtualization functions. Pluralinstances can be provided for components, operations, or structuresdescribed herein as a single instance. Finally, boundaries betweenvarious components, operations, and data stores are somewhat arbitrary,and particular operations are illustrated in the context of specificillustrative configurations. Other allocations of functionality areenvisioned and may fall within the scope of the invention(s). Ingeneral, structures and functionality presented as separate componentsin exemplary configurations can be implemented as a combined structureor component. Similarly, structures and functionality presented as asingle component can be implemented as separate components.

As used in the description herein and throughout the claims that follow,“a,” “an,” and “the” includes plural references unless the contextclearly dictates otherwise. Also, as used in the description herein andthroughout the claims that follow, the meaning of “in” includes “in” and“on” unless the context clearly dictates otherwise.

The above description illustrates various embodiments along withexamples of how aspects of particular embodiments may be implemented.These examples and embodiments should not be deemed to be the onlyembodiments, and are presented to illustrate the flexibility andadvantages of particular embodiments as defined by the following claims.Other arrangements, embodiments, implementations and equivalents can beemployed without departing from the scope hereof as defined by theclaims.

What is claimed is:
 1. A method for optimizing central processing unit(CPU) usage in a host system based on virtual machine (VM) guestoperating system (OS) power or performance management, the methodcomprising: empowering, by a hypervisor of the host system, a guest OSof a VM running on the hypervisor to execute a power or performancemanagement mechanism that is supported by the guest OS, wherein theempowering comprises making visible to the guest OS a virtual CPUtopology that includes a cluster of higher performance virtual CPUs(vCPUs) and a cluster of lower performance vCPUs, and wherein thehypervisor makes the virtual CPU topology visible to the guest OS bypassing, to the guest OS, a processor identifier for each of the higherperformance vCPUs and lower performance vCPUs that indicates the vCPU'sperformance class; capturing, by the hypervisor, information from theguest OS pertaining to a target power or performance state set by theguest OS with respect to at least one vCPU of the VM; and performing, bythe hypervisor, one or more actions based on the information that alignusage of host CPU resources by the vCPU with the target power orperformance state.
 2. The method of claim 1 wherein the capturingcomprises: trapping, by the hypervisor, a CPU power off instructionissued by the guest OS with respect to the vCPU.
 3. The method of claim2 wherein the one or more actions include tearing down contextinformation maintained by the hypervisor for the vCPU.
 4. The method ofclaim 1 wherein the empowering further comprises: emulating, by thehypervisor, one or more vCPU performance control registers as defined inthe Advanced Configuration and Power Interface (ACPI) CollaborativeProcessor Performance Control (CPPC) standard; and exposing, by thehypervisor, the emulated vCPU performance control registers to the guestOS.
 5. The method of claim 1 wherein the one or more actions include:modifying, by the hypervisor, a host CPU time slice allocated to thevCPU, or scheduling, by the hypervisor, work for the vCPU on a differenthost CPU.
 6. The method of claim 1 wherein each processor identifier ispassed to the guest OS via a predefined vCPU register.
 7. Anon-transitory computer readable storage medium having stored thereonprogram code executable by a hypervisor of a host system, the programcode embodying a method for optimizing central processing unit (CPU)usage in the host system based on virtual machine (VM) guest operatingsystem (OS) power or performance management, the method comprising:empowering a guest OS of a VM running on the hypervisor to execute apower or performance management mechanism that is supported by the guestOS, wherein the empowering comprises making visible to the guest OS avirtual CPU topology that includes a cluster of higher performancevirtual CPUs (vCPUs) and a cluster of lower performance vCPUs, andwherein the hypervisor makes the virtual CPU topology visible to theguest OS by passing, to the guest OS, a processor identifier for each ofthe higher performance vCPUs and lower performance vCPUs that indicatesthe vCPU's performance class; capturing information from the guest OSpertaining to a target power or performance state set by the guest OSwith respect to at least one vCPU of the VM; and performing one or moreactions based on the information that align usage of host CPU resourcesby the vCPU with the target power or performance state.
 8. Thenon-transitory computer readable storage medium of claim 7 wherein thecapturing comprises: trapping a CPU power off instruction issued by theguest OS with respect to the vCPU.
 9. The non-transitory computerreadable storage medium of claim 8 wherein the one or more actionsinclude tearing down context information maintained by the hypervisorfor the vCPU.
 10. The non-transitory computer readable storage medium ofclaim 7 wherein the empowering further comprises: emulating one or morevCPU performance control registers as defined in the AdvancedConfiguration and Power Interface (ACPI) Collaborative ProcessorPerformance Control (CPPC) standard; and exposing the emulated vCPUperformance control registers to the guest OS.
 11. The non-transitorycomputer readable storage medium of claim 7 wherein the one or moreactions include: modifying, a host CPU time slice allocated to the vCPU,or scheduling work for the vCPU on a different host CPU.
 12. Thenon-transitory computer readable storage medium of claim 7 wherein eachprocessor identifier is passed to the guest OS via a predefined vCPUregister.
 13. A host system comprising: a plurality of host centralprocessing units (CPUs); a hypervisor; a virtual machine (VM) running ontop of the hypervisor, the VM including a guest operating system (OS);and a non-transitory computer readable medium having stored thereonprogram code that, when executed by the hypervisor, causes thehypervisor to: empower the guest OS to execute a power or performancemanagement mechanism that is supported by the guest OS, wherein theempowering comprises making visible to the guest OS a virtual CPUtopology that includes a cluster of higher performance virtual CPUs(vCPUs) and a cluster of lower performance vCPUs, and wherein thehypervisor makes the virtual CPU topology visible to the guest OS bypassing, to the guest OS, a processor identifier for each of the higherperformance vCPUs and lower performance vCPUs that indicates the vCPU'sperformance class; capture information from the guest OS pertaining to atarget power or performance state set by the guest OS with respect to atleast one vCPU of the VM; and perform, based on the information, one ormore actions that align usage of the host CPUs by the vCPU with thetarget power or performance state.
 14. The host system of claim 13wherein the capturing comprises: trapping a CPU power off instructionissued by the guest OS with respect to the vCPU.
 15. The host system ofclaim 14 wherein the one or more actions include tearing down contextinformation maintained by the hypervisor for the vCPU.
 16. The hostsystem of claim 13 wherein the empowering further comprises: emulatingone or more vCPU performance control registers as defined in theAdvanced Configuration and Power Interface (ACPI) CollaborativeProcessor Performance Control (CPPC) standard; and exposing the emulatedvCPU performance control registers to the guest OS.
 17. The host systemof claim 13 wherein the one or more actions include: modifying, a hostCPU time slice allocated to the vCPU, or scheduling work for the vCPU ona different host CPU.
 18. The host system of claim 13 wherein eachprocessor identifier is passed to the guest OS via a predefined vCPUregister.